package com.purchase.ml.mapper.sys;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.purchase.ml.bean.req.sys.SysUserQueryDto;
import com.purchase.ml.bean.res.sys.SysRes;
import com.purchase.ml.entity.acc.SysUser;
import com.purchase.ml.entity.dealer.SysDealer;
import com.purchase.ml.entity.sys.SysPermission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* <p>
    *  Mapper 接口
    * </p>
*
* @author kyyang
* Created 2021-01-05
*/
    @Mapper
    @Repository
public interface SysUserMapper extends BaseMapper<SysUser> {

    @Select("select * from sys_user where acc = #{acc}")
    SysUser selectByAccount(@Param("acc") String userName);

    List<SysPermission> selectCurrentPer(@Param("userId") Long userId, @Param("permissionId") Integer permissionId);

    List<SysPermission> selectCurrentMenu(@Param("userId") Long userId);

    @Select("select acc from sys_user where dealer_id = #{dealerId}")
    List<String> selectByMerchantId(@Param("dealerId") Long merchantId);

    List<SysRes> selectAccPages(@Param("dto") SysUserQueryDto dto);

    @Select("select * from sys_user where email=#{email} ")
    SysUser selectAccByEmail(@Param("email")String email);

    @Update("update sys_user set state = #{state} where dealer_id = #{dealerId}")
    int updateAccState(@Param("dealerId") Long dealerId,@Param("state") int state);

    @Select("select acc,name from sys_user where dealer_id=#{dealerId} ")
    SysUser selectByDealerId(@Param("dealerId")Long dealerId);
}
